To update UITextView height with it’s content height, you need to update the correspond height constraint. Otherwise, it won’t work.
1 2 3 4 5 6 7 8 9
| extension UITextView { func heightThatFitsContent() -> CGFloat { let fixedWidth = self.frame.width let newSize = self.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat(MAXFLOAT))) return newSize.height } } textViewHeightConstraint.constant = textview.heightThatFitsContent()
|